<template>
<div>
    <el-tabs v-model="activeName" @tab-click="tabclick">
        <el-tab-pane label="团购优惠" name="1">
            <div class="Preferentiaheader">
                <div>
                    <el-button type="primary" @click="openAudit">批量审核</el-button>
                    <el-button type="primary" @click="openAddbulk">添加团购优惠</el-button>
                </div>
                <div>
                    <PreferentialSearch></PreferentialSearch>
                </div>
            </div>
            <PreferentialTable></PreferentialTable>
        </el-tab-pane>
        <el-tab-pane label="限时抢购" name="2">
            <div class="Preferentiaheader">
                <div>
                    <el-button type="primary">批量审核</el-button>
                    <el-button type="primary" @click="openAddbulk">新增限时抢购</el-button>
                </div>
                <div>
                    <PreferentialSearch></PreferentialSearch>
                </div>
            </div>
            <PreferentialTable></PreferentialTable>
        </el-tab-pane>
        <el-tab-pane label="购房补贴" name="3">
            <div class="Preferentiaheader">
                <div>
                    <el-button type="primary">批量审核</el-button>
                    <el-button type="primary" @click="openAddbulk">新增购房补贴</el-button>
                </div>
                <div>
                    <PreferentialSearch></PreferentialSearch>
                </div>
            </div>
            <PreferentialTable></PreferentialTable>
        </el-tab-pane>
    </el-tabs>
    <!-- <el-tabs v-model="activeName" type="card" >
            <el-tab-pane
                v-for="(item) in editableTabs1"
                :key="item.name"
                :label="item.title"
                :name="item.name">
                <component :is='item.content'></component>
                <component :is='item.content1'></component>
            </el-tab-pane>
    </el-tabs>-->
    <Addbulk></Addbulk>
    <Audit></Audit>
</div>
</template>

<script>
import RefundSearch from "../components/RefundSearch";
import PreferentialTable from "../components/PreferentialTable";
import PreferentialSearch from "../components/PreferentialSearch";
import Addbulk from "../components/Addbulk";
import Audit from "../components/Audit";
import * as api from "../utils/api";

export default {
    components: {
        RefundSearch,
        PreferentialTable,
        PreferentialSearch,
        Addbulk,
        Audit,
    },
    data() {
        return {
            title: "",
            activeName: "1",
            editableTabs1: [{
                    title: "团购优惠",
                    name: "1",
                    content: "RefundSearch",
                    content1: "PreferentialTable",
                },
                {
                    title: "限时抢购",
                    name: "2",
                    content: "RefundSearch",
                    content1: "PreferentialTable",
                },
                {
                    title: "购房补贴",
                    name: "3",
                    content: "RefundSearch",
                    content1: "PreferentialTable",
                },
            ],
        };
    },
    methods: {
        openAudit() {
            this.$store.dispatch("changeAuditDialogActions");
        },
        openAddbulk() {
            let row1 = {
                active_status: "",
                activity_img: "",
                activity_time_end: "",
                activity_time_start: "",
                event_title: "",
                file: "",
                group_purchase_discount_id: "",
                how_to_use: "",
                join_member_fee: "",
                no_pass_reason: "",
                number_of_initial_entries: "",
                number_of_people_registered: "",
                offer_details: "",
                pledge: "",
                real_estate_id: "",
                recommended_reason: "",
                scope_of_application: "",
                total_circulation: "",
                validity_period: "",
            };

            this.$store.dispatch("changeDialogActions");
            this.$store.dispatch("changebulkDataActions", row1);
            let bulkState = this.$store.state.PreferentialData.bulkState;
            if (bulkState === "1") {
                this.$store.dispatch("changebulkTitleActions", "新增团购优惠");
            }
            if (bulkState === "2") {
                this.$store.dispatch("changebulkTitleActions", "新增限时抢购");
            }
            if (bulkState === "3") {
                this.$store.dispatch("changebulkTitleActions", "新增购房补贴");
            }
        },
        tabclick() {
            // console.log(this.activeName)
            this.$store.dispatch("changeBulkStateActions", this.activeName);
            this.getTableData(1, 5);
        },
        getTableData(nowPage, perPageNum) {
            let data = function (a, b) {
                this.nowPage = a;
                this.perPageNum = b;
            };
            const data1 = new data(nowPage, perPageNum);
            this.$store.dispatch("gettableDataActions", data1);
        },
    },
    created() {
        this.getTableData(1, 5);
        // this.axios({
        //     url: api.ltb_queryLimitedTimeBuying,
        //     method: 'get',
        //     params: {
        //         currentPage: '1',
        //         pageSize: '3',
        //     }
        // }).then(data=>{
        //     console.log(data);
        // })
    },
};
</script>

<style lang="less" scoped>
.Preferentiaheader {
    div {
        &:nth-of-type(1) {
            float: left;
        }

        &:nth-of-type(2) {
            float: right;
        }
    }
}

.el-button {
    margin-right: 5px;
}
</style>
